package cn.com.guage.dtm.huawei;

import java.util.*;

public class HJ3_明明的随机数 {
    public static void main(String[] args) {
       // method1();
       // method2();
        method3();
    }

    /**
     * 利用HashSet进行元素去重
     * 利用 Collections.sort(list)对元素进行排序
     */
    private static void method1(){
        Scanner sc = new Scanner(System.in);
        Integer numberSum = sc.nextInt();
        //HashSet为无需的并且元素不重复的集合
        Set<Integer> set = new HashSet<Integer>();
        for (int i = 0; i < numberSum; i++) {
            Integer digital = sc.nextInt();
            set.add(digital);
        }
        List<Integer> list = new ArrayList<Integer>();
        for (Integer integer : set) {
            list.add(integer);
        }
        //Collections可以对List集合进行排序
        Collections.sort(list);
        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i));
        }
    }

    /**
     * 利用TreeSet可以对数据进行去重并且排序
     */
    private static void method2(){
        Scanner sc = new Scanner(System.in);
        Integer numberSum = sc.nextInt();
        TreeSet<Integer> treeSet = new TreeSet<Integer>();
        for (int i = 0; i < numberSum; i++) {
            Integer digital = sc.nextInt();
            treeSet.add(digital);
        }
        for (int i = 0; i < treeSet.size(); i++) {
            System.out.println(treeSet.toArray()[i]);
        }
    }

    /**
     * 利用TreeSet可以对数据进行去重并且排序
     * 利用treeSet.iterator()将数据输出
     */
    private static void method3(){
        Scanner sc = new Scanner(System.in);
        Integer numberSum = sc.nextInt();
        TreeSet<Integer> treeSet = new TreeSet<Integer>();
        for (int i = 0; i < numberSum; i++) {
            Integer digital = sc.nextInt();
            treeSet.add(digital);
        }
        Iterator iterator = treeSet.iterator();
        while (iterator.hasNext()){
            System.out.println(iterator.next());
        }
    }
}
